
import random
from typing import List

def generate_test_data():
    """生成测试数据"""
    test_cases = []
    
    # 基础测试用例
    test_cases.append([[1, 3, 1], [1, 5, 1], [4, 2, 1]])  # 经典示例
    test_cases.append([[1, 2, 3], [4, 5, 6]])  # 简单矩形
    test_cases.append([[1]])  # 单元素
    test_cases.append([[1, 2, 3, 4, 5]])  # 单行
    test_cases.append([[1], [2], [3], [4]])  # 单列
    
    # 随机生成测试用例
    for _ in range(5):
        m = random.randint(2, 10)  # 行数
        n = random.randint(2, 10)  # 列数
        grid = [[random.randint(1, 100) for _ in range(n)] for _ in range(m)]
        test_cases.append(grid)
    
    return test_cases

# 测试代码
if __name__ == "__main__":
    solution = Solution()
    test_cases = generate_test_data()
    
    for i, grid in enumerate(test_cases):
        result = solution.minPathSum(grid)
        print(f"测试用例 {i+1}:")
        for row in grid:
            print(row)
        print(f"最小路径和: {result}\n")
